@{
    // delete comment
    // INIT VARS
    string ErrorMessage="";
    string SuccessMessage="";
    // Get USER ID
    var  userId = WebSecurity.CurrentUserId;
    // GET COMMENT ID
    var CommentId = UrlData[0];
    // set view
    var view ="~/Actions/Admin/ListAllComments";
    
    // check if registered user is the auhor of the article where the comment comes from
    // if not redirect
    
    var Comment = Blog.DataObject.GetCommentByArticleIdAndUserId(userId.ToString(),CommentId);
    if(String.IsNullOrEmpty(Comment.id.ToString())){
    // user cannot delete comment as the article where the comment was posted doesnt belong to the current user
    Response.Redirect("~/");
    }
    // Delete comment
    var deletedComment = Blog.DataObject.DeleteCommentById(CommentId);
    
    // test if deletion is successfull
    if(deletedComment>0){
        SuccessMessage = "Comment successfully deleted";
    }else{
        ErrorMessage = "Comment not deleted";
    }
    // Redirect to view
    Response.Redirect(@Href(view,new{SuccessMessage = SuccessMessage , ErrorMessage = ErrorMessage }));
}